home *** CD-ROM | disk | FTP | other *** search
/ Kit PC World De Ampliacion De Windows 95 / Kit PC World de ampliacion de Windows 95.iso / clarion / cw15 / tpw15.z / CONTROL.TPW < prev    next >
Text File  |  1995-08-25  |  48KB  |  1,445 lines

  1. #!----------------------------------------------------------------
  2. #CONTROL(CloseButton,'Close the Window'),WINDOW,HLP('~TPLControlCloseButton')
  3.   CONTROLS
  4.     BUTTON('Close'),USE(?Close)
  5.   END
  6. #ATSTART
  7.   #DECLARE(%CloseControl)
  8.   #FOR(%Control),WHERE(%ControlInstance=%ActiveTemplateInstance)
  9.     #SET(%CloseControl,%Control)
  10.   #ENDFOR
  11. #ENDAT
  12. #AT(%ControlEventHandling,%CloseControl,'Accepted')
  13. LocalResponse = RequestCancelled
  14. POST(Event:CloseWindow)
  15. #ENDAT
  16. #!----------------------------------------------------------------
  17. #CONTROL(CancelButton,'Cancel the Current Operation'),WINDOW,HLP('~TPLControlCancelButton')
  18.   CONTROLS
  19.     BUTTON('Cancel'),USE(?Cancel)
  20.   END
  21. #ATSTART
  22.   #DECLARE(%CancelControl)
  23.   #FOR(%Control),WHERE(%ControlInstance=%ActiveTemplateInstance)
  24.     #SET(%CancelControl,%Control)
  25.   #ENDFOR
  26. #ENDAT
  27. #AT(%ControlEventHandling,%CancelControl,'Accepted')
  28. LocalResponse = RequestCancelled
  29. POST(Event:CloseWindow)
  30. #ENDAT
  31. #!----------------------------------------------------------------
  32. #CONTROL(SaveButton,'Write Records to a data file'),PRIMARY('Update Record on Disk',NOKEY),DESCRIPTION('Update ' & %Primary & ' record on disk'),WINDOW,HLP('~TPLControlSaveButton')
  33.   CONTROLS
  34.     BUTTON('OK'),USE(?OK),DEFAULT,REQ
  35.   END
  36. #LOCALDATA
  37. ActionMessage        CSTRING(40)
  38. RecordChanged        BYTE,AUTO
  39. #ENDLOCALDATA
  40. #CLASS('Prime Fields','Prime Fields of ' & %Primary & ' record at beginning of Insert')
  41. #BOXED('Save Button Properties')
  42.   #DISPLAY('Allow:')
  43.   #PROMPT('Inserts',CHECK),%InsertAllowed,DEFAULT(%True),AT(50,9,40)
  44.   #PROMPT('Changes',CHECK),%ChangeAllowed,DEFAULT(%True),AT(100,9,40)
  45.   #PROMPT('Deletes',CHECK),%DeleteAllowed,DEFAULT(%True),AT(150,9,40)
  46.   #ENABLE(%DeleteAllowed = %True)
  47.     #PROMPT('When called for delete:',DROP('Standard Warning|Display Form|Automatic Delete')),%ActionOnDelete,DEFAULT('Standard Warning')
  48.   #ENDENABLE
  49.   #ENABLE(%InsertAllowed = %True)
  50.     #BUTTON('Field Priming on Insert'),MULTI(%PrimingFields,%PrimedField & ' = ' & %PrimedValue),AT(10),HLP('~TPLControlSaveButton')
  51.       #PROMPT('Field to Prime:',FIELD),%PrimedField,REQ
  52.       #PROMPT('Initial Value:',@S255),%PrimedValue,REQ
  53.     #ENDBUTTON
  54.   #ENDENABLE
  55.   #BUTTON('Messages and Titles'),HLP('TPLControlSaveButton'),HLP('~TPLControlSaveButton')
  56.     #ENABLE(%InsertAllowed = %True)
  57.       #PROMPT('&Insert Message:',@S40),%InsertMessage,DEFAULT('Record will be Added')
  58.     #ENDENABLE
  59.     #ENABLE(%ChangeAllowed = %True)
  60.       #PROMPT('Chan&ge Message:',@S40),%ChangeMessage,DEFAULT('Record will be Changed')
  61.     #ENDENABLE
  62.     #ENABLE(%DeleteAllowed = %True)
  63.       #PROMPT('De&lete Message:',@S40),%DeleteMessage,DEFAULT('Record will be Deleted')
  64.     #ENDENABLE
  65.     #ENABLE(%InsertAllowed OR %ChangeAllowed)
  66.       #PROMPT('On Aborted Add/Change:',DROP('Offer to save changes|Confirm cancel|Cancel without confirming')),%ActionOnCancel,DEFAULT('Offer to save changes')
  67.     #ENDENABLE
  68.     #PROMPT('&Location of Message:',DROP('None/Window Control|Title Bar|Status Bar')),%MessageLocation
  69.     #ENABLE(%MessageLocation='Status Bar')
  70.       #PROMPT('Status Bar Section:',@n1),%MessageStatusSection,REQ
  71.     #ENDENABLE
  72.     #PROMPT('Display Record Identifier on the Title Bar',CHECK),%AppendToTitle,AT(10,,180)
  73.     #ENABLE(%AppendToTitle = %True)
  74.       #PROMPT('Record Identifier:',@S255),%AppendToTitleID,REQ
  75.     #ENDENABLE
  76.   #ENDBUTTON
  77. #ENDBOXED
  78. #AT(%CustomGlobalDeclarations)
  79.   #INSERT(%StandardGlobalSetup)
  80. #ENDAT
  81. #ATSTART
  82.   #INSERT(%FileControlInitialize)
  83.   #DECLARE(%HandledFile),UNIQUE
  84.   #DECLARE(%InsertAction,%HandledFile)
  85.   #DECLARE(%FirstHandledValue)
  86.   #DECLARE(%LastHandledValue)
  87.   #INSERT(%SaveButtonRecordHandlingGather,%Primary)
  88.   #DECLARE(%AutoIncrementOnAdd)
  89.   #DECLARE(%ClearValue)
  90.   #DECLARE(%ElementCount)
  91.   #DECLARE(%OKControl)
  92.   #DECLARE(%SavedField),UNIQUE
  93.   #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  94.     #SET(%OKControl,%Control)
  95.   #ENDFOR
  96.   #FIX(%File,%Primary)
  97.   #IF(%InsertAllowed)
  98.     #FOR(%Key),WHERE(%KeyAuto)
  99.       #SET(%AutoIncrementOnAdd,%True)
  100.       #BREAK
  101.     #ENDFOR
  102.   #ENDIF
  103. #ENDAT
  104. #AT(%DataSectionBeforeWindow)
  105.   #FOR(%HandledFile)
  106. #INSERT(%SaveButtonRecordHandler,'DECLARE',%HandledFile)
  107.   #ENDFOR
  108.   #FIX(%File,%Primary)
  109.   #IF(%AutoIncrementOnAdd)
  110. Auto::Attempts       LONG,AUTO
  111.     #FOR(%Key),WHERE(%KeyAuto)
  112.       #FOR(%KeyField)
  113.         #FIX(%SavedField,%KeyField)
  114.         #IF(%SavedField <> %KeyField)
  115.           #ADD(%SavedField,%KeyField)
  116.           #FIX(%Field,%KeyField)
  117.           #IF(%FieldType='GROUP')
  118. Auto::Save:%[12]Field LIKE(%Field),PRE(SV)
  119.           #ELSE
  120. Auto::Save:%[12]Field LIKE(%Field)
  121.           #ENDIF
  122.         #ENDIF
  123.       #ENDFOR
  124.     #ENDFOR
  125.   #ENDIF
  126. #ENDAT
  127. #AT(%AfterFileOpen)
  128. RISnap:%Primary
  129.   #FOR(%HandledFile)
  130. #INSERT(%SaveButtonRecordHandler,'SET',%HandledFile)
  131.   #ENDFOR
  132.   #IF(%InsertAllowed)
  133. IF LocalRequest = InsertRecord
  134.   #EMBED(%OnInsertBeforePriming,'On Insert, before record is primed')
  135.   DO PrimeFields
  136.   #EMBED(%OnInsertAfterPriming,'On Insert, after record is primed')
  137. END
  138.   #ENDIF
  139.   #IF(%DeleteAllowed)
  140.     #IF(%ActionOnDelete = 'Standard Warning')
  141. IF LocalRequest = DeleteRecord
  142.   IF StandardWarning(Warn:StandardDelete) = Button:OK
  143.     LOOP
  144.       LocalResponse = RequestCancelled
  145.       SETCURSOR(Cursor:Wait)
  146.       IF RIDelete:%Primary()
  147.         SETCURSOR()
  148.         CASE StandardWarning(Warn:DeleteError)
  149.         OF Button:Yes
  150.           CYCLE
  151.         OF Button:No OROF Button:Cancel
  152.           BREAK
  153.         END
  154.       ELSE
  155.         SETCURSOR()
  156.         LocalResponse = RequestCompleted
  157.       END
  158.       BREAK
  159.     END
  160.   END
  161.   DO ProcedureReturn
  162. END
  163.     #ELSIF(%ActionOnDelete = 'Automatic Delete')
  164. IF LocalRequest = DeleteRecord
  165.   LOOP
  166.     LocalResponse = RequestCancelled
  167.     SETCURSOR(Cursor:Wait)
  168.     IF RIDelete:%Primary()
  169.       SETCURSOR()
  170.       CASE StandardWarning(Warn:DeleteError)
  171.       OF Button:Yes
  172.         CYCLE
  173.       OF Button:No OROF Button:Cancel
  174.         BREAK
  175.       END
  176.     ELSE
  177.       SETCURSOR()
  178.       LocalResponse = RequestCompleted
  179.     END
  180.     BREAK
  181.   END
  182.   DO ProcedureReturn
  183. END
  184.     #ENDIF
  185.   #ENDIF
  186. #ENDAT
  187. #AT(%BeforeAccept)
  188. CASE LocalRequest
  189. OF InsertRecord
  190.   #IF(%InsertAllowed)
  191.     #IF(%InsertMessage)
  192.   #INSERT(%StandardValueAssignment,'ActionMessage',%InsertMessage)
  193.     #ELSE
  194.   CLEAR(ActionMessage)
  195.     #ENDIF
  196.   #ELSE
  197.   IF StandardWarning(Warn:InsertDisabled)
  198.     RETURN
  199.   END
  200.   #ENDIF
  201. OF ChangeRecord
  202.   #IF(%ChangeAllowed)
  203.     #IF(%ChangeMessage)
  204.   #INSERT(%StandardValueAssignment,'ActionMessage',%ChangeMessage)
  205.     #ELSE
  206.   CLEAR(ActionMessage)
  207.     #ENDIF
  208.   #ELSE
  209.   IF StandardWarning(Warn:UpdateDisabled)
  210.     RETURN
  211.   END
  212.   #ENDIF
  213. OF DeleteRecord
  214.   #IF(%DeleteAllowed)
  215.     #IF(%ActionOnDelete = 'Display Form')
  216.       #IF(%DeleteMessage)
  217.   #INSERT(%StandardValueAssignment,'ActionMessage',%DeleteMessage)
  218.       #ELSE
  219.   CLEAR(ActionMessage)
  220.       #ENDIF
  221.     #ENDIF
  222.   #ELSE
  223.    IF StandardWarning(Warn:DeleteDisabled)
  224.     RETURN
  225.   END
  226.   #ENDIF
  227. END
  228.   #IF(%MessageLocation = 'Title Bar')
  229. %Window{Prop:Text} = ActionMessage
  230.   #ELSIF(%MessageLocation = 'Status Bar')
  231. %Window{Prop:StatusText,%MessageStatusSection} = ActionMessage
  232.   #ENDIF
  233.   #IF(%AppendToTitle)
  234.     #IF(%DeleteAllowed OR %ChangeAllowed OR %InsertAllowed)
  235. CASE LocalRequest
  236.       #IF(%DeleteAllowed OR %ChangeAllowed)
  237.         #IF(%DeleteAllowed AND %ChangeAllowed)
  238. OF ChangeRecord OROF DeleteRecord
  239.         #ELSIF(%ChangeAllowed)
  240. OF ChangeRecord
  241.         #ELSE
  242. OF DeleteRecord
  243.         #ENDIF
  244.         #IF(SUB(%AppendToTitleID,1,1)='!')
  245.           #SET(%ValueConstruct,SUB(%AppendToTitleID,2,LEN(%AppendToTitleID)-1))
  246.   %Window{Prop:Text} = %Window{Prop:Text} & '  (' & CLIP(%ValueConstruct) & ')'
  247.         #ELSE
  248.   %Window{Prop:Text} = %Window{Prop:Text} & '  (%AppendToTitleID)'
  249.         #ENDIF
  250.       #ENDIF
  251.       #IF(%InsertAllowed)
  252. OF InsertRecord
  253.   %Window{Prop:Text} = %Window{Prop:Text} & '  (New)'
  254.       #ENDIF
  255. END
  256.     #ENDIF
  257.   #ENDIF
  258. #ENDAT
  259. #AT(%WindowEventHandling,'CloseWindow')
  260. IF LocalResponse <> RequestCompleted
  261.   #IF(%ActionOnCancel = 'Offer to save changes' OR %ActionOnCancel = 'Confirm cancel')
  262.   RecordChanged = False
  263.     #IF(%InsertAllowed OR %ChangeAllowed)
  264.       #IF(%InsertAllowed AND %ChangeAllowed)
  265.   IF LocalRequest = InsertRecord OR LocalRequest = ChangeRecord
  266.       #ELSIF(%InsertAllowed)
  267.   IF LocalRequest = InsertRecord
  268.       #ELSE
  269.   IF LocalRequest = ChangeRecord
  270.       #ENDIF
  271.       #FOR(%HandledFile)
  272.     #INSERT(%SaveButtonRecordHandler,'CHECK',%HandledFile)
  273.       #ENDFOR
  274.       #FIX(%File,%FilePrefix)
  275.   END
  276.   IF RecordChanged
  277.       #IF(%ActionOnCancel = 'Offer to save changes')
  278.     CASE StandardWarning(Warn:SaveOnCancel)
  279.     OF Button:Yes
  280.       POST(Event:Accepted,%OKControl)
  281.       CYCLE
  282.     OF Button:No
  283.     OF BUTTON:Cancel
  284.       SELECT(%FirstField)
  285.       CYCLE
  286.     END
  287.       #ELSE
  288.     IF StandardWarning(Warn:ConfirmCancel) = Button:No
  289.       SELECT(%FirstField)
  290.       CYCLE
  291.     END
  292.       #ENDIF
  293.   END
  294.     #ENDIF
  295.   #ENDIF
  296.   #IF(%AutoIncrementOnAdd)
  297.   IF OriginalRequest = InsertRecord
  298.     IF LocalResponse = RequestCancelled
  299.       DELETE(%Primary)
  300.     END
  301.   END
  302.   #ENDIF
  303. END
  304. #ENDAT
  305. #AT(%WindowEventHandling,'CloseDown')
  306. IF LocalResponse <> RequestCompleted
  307.   #IF(%ActionOnCancel = 'Offer to save changes' OR %ActionOnCancel = 'Confirm cancel')
  308.   RecordChanged = False
  309.     #IF(%InsertAllowed OR %ChangeAllowed)
  310.       #IF(%InsertAllowed AND %ChangeAllowed)
  311.   IF LocalRequest = InsertRecord OR LocalRequest = ChangeRecord
  312.       #ELSIF(%InsertAllowed)
  313.   IF LocalRequest = InsertRecord
  314.       #ELSE
  315.   IF LocalRequest = ChangeRecord
  316.       #ENDIF
  317.       #FOR(%HandledFile)
  318.     #INSERT(%SaveButtonRecordHandler,'CHECK',%HandledFile)
  319.       #ENDFOR
  320.       #FIX(%File,%FilePrefix)
  321.   END
  322.   IF RecordChanged
  323.       #IF(%ActionOnCancel = 'Offer to save changes')
  324.     CASE StandardWarning(Warn:SaveOnCancel)
  325.     OF Button:Yes
  326.       POST(Event:Accepted,%OKControl)
  327.       CYCLE
  328.     OF Button:No
  329.     OF BUTTON:Cancel
  330.       SELECT(%FirstField)
  331.       CYCLE
  332.     END
  333.       #ELSE
  334.     IF StandardWarning(Warn:ConfirmCancel) = Button:No
  335.       SELECT(%FirstField)
  336.       CYCLE
  337.     END
  338.       #ENDIF
  339.   END
  340.     #ENDIF
  341.   #ENDIF
  342.   #IF(%AutoIncrementOnAdd)
  343.   IF OriginalRequest = InsertRecord
  344.     IF LocalResponse = RequestCancelled
  345.       DELETE(%Primary)
  346.     END
  347.   END
  348.   #ENDIF
  349. END
  350. #ENDAT
  351. #AT(%WindowOtherEventHandling)
  352.   #FIX(%File,%Primary)
  353. IF EVENT() = Event:Completed
  354.   #EMBED(%BeforeFileAction,'When completed, before writing to disk')
  355.   CASE LocalRequest
  356.   #IF(%InsertAllowed)
  357.   OF InsertRecord
  358.     #IF(%AutoIncrementOnAdd)
  359.     PUT(%Primary)
  360.     #ELSE
  361.     ADD(%Primary)
  362.     #END
  363.     CASE ERRORCODE()
  364.     OF NoError
  365.       LocalResponse = RequestCompleted
  366.       POST(Event:CloseWindow)
  367.       #SUSPEND
  368.     #?OF DupKeyErr
  369.         #DECLARE(%FirstKeyRead)
  370.         #FOR(%Key),WHERE(NOT %KeyDuplicate)
  371.           #IF(%FirstKeyRead)
  372.       ELSIF DUPLICATE(%Key)
  373.           #ELSE
  374.       IF DUPLICATE(%Key)
  375.           #ENDIF
  376.           #IF(%KeyDescription)
  377.         IF StandardWarning(Warn:DuplicateKey,'%KeyDescription')
  378.           #ELSE
  379.         IF StandardWarning(Warn:DuplicateKey,'%Key')
  380.           #ENDIF
  381.           SELECT(%FirstField)
  382.           CYCLE
  383.         END
  384.       END
  385.         #ENDFOR
  386.       #RESUME
  387.     ELSE
  388.       IF StandardWarning(Warn:InsertError)
  389.         SELECT(%FirstField)
  390.         CYCLE
  391.       END
  392.     END
  393.   #ENDIF
  394.   #IF(%ChangeAllowed)
  395.   OF ChangeRecord
  396.     LOOP
  397.       LocalResponse = RequestCancelled
  398.       SETCURSOR(Cursor:Wait)
  399.       IF RIUpdate:%Primary()
  400.         SETCURSOR()
  401.         CASE StandardWarning(Warn:UpdateError)
  402.         OF Button:Yes
  403.           CYCLE
  404.         OF Button:No
  405.           POST(Event:CloseWindow)
  406.           BREAK
  407.         OF Button:Cancel
  408.           DISPLAY
  409.           SELECT(%FirstField)
  410.           BREAK
  411.         END
  412.       ELSE
  413.         SETCURSOR()
  414.         LocalResponse = RequestCompleted
  415.         POST(Event:CloseWindow)
  416.       END
  417.       BREAK
  418.     END
  419.   #ENDIF
  420.   #IF(%DeleteAllowed AND %ActionOnDelete = 'Display Form')
  421.   OF DeleteRecord
  422.     LOOP
  423.       LocalResponse = RequestCancelled
  424.       SETCURSOR(Cursor:Wait)
  425.       IF RIDelete:%Primary()
  426.         SETCURSOR()
  427.         CASE StandardWarning(Warn:DeleteError)
  428.         OF Button:Yes
  429.           CYCLE
  430.         OF Button:No
  431.           POST(Event:CloseWindow)
  432.           BREAK
  433.         OF Button:Cancel
  434.           DISPLAY
  435.           SELECT(%FirstField)
  436.           BREAK
  437.         END
  438.       ELSE
  439.         SETCURSOR()
  440.         LocalResponse = RequestCompleted
  441.         POST(Event:CloseWindow)
  442.       END
  443.       BREAK
  444.     END
  445.   #ENDIF
  446.   END
  447. END
  448. #ENDAT
  449. #AT(%ControlEventHandling,%OKControl,'Accepted')
  450. IF OriginalRequest = ChangeRecord OR OriginalRequest = InsertRecord
  451.   SELECT()
  452. ELSE
  453.   POST(EVENT:Completed)
  454. END
  455. #ENDAT
  456. #AT(%RefreshWindowBeforeLookup)
  457. #INSERT(%StandardSecondaryLookups)
  458. #ENDAT
  459. #AT(%ProcedureRoutines)
  460. #DECLARE(%SetNecessary)
  461. #SET(%SetNecessary,%False)
  462.   #IF(%InsertAllowed)
  463. PrimeFields ROUTINE
  464.     #SUSPEND
  465.     #FIX(%File,%Primary)
  466.   #INSERT(%SaveButtonRecordHandler,'RESET',%Primary)
  467.     #FOR(%Field),WHERE(%FieldInitial)
  468.   %Field = %FieldInitial
  469.     #ENDFOR
  470.     #FOR(%PrimingFields)
  471.   %PrimedField = %PrimedValue
  472.     #ENDFOR
  473.   #EMBED(%PrimeFields,'Prime record fields on Insert'),WHERE(%InsertAllowed)
  474.   #INSERT(%SaveButtonRecordHandler,'SET',%Primary)
  475.     #RESUME
  476.   #ENDIF
  477.   #IF(%AutoIncrementOnAdd)
  478.   Auto::Attempts = 0
  479.   LOOP
  480.     #FOR(%Key),WHERE(%KeyAuto)
  481.       #IF(ITEMS(%KeyField)>1)
  482.         #FOR(%KeyField)
  483.           #IF(%KeyField=%KeyAuto)
  484.             #IF(%KeyFieldSequence = 'ASCENDING')
  485.               #SET(%ClearValue,'1')
  486.             #ELSE
  487.               #SET(%Clearvalue,'-1')
  488.             #ENDIF
  489.           #ENDIF
  490.         #ENDFOR
  491.         #FOR(%KeyField),WHERE(%KeyField <> %KeyAuto)
  492.     Auto::Save:%KeyField = %KeyField
  493.         #ENDFOR
  494.     CLEAR(%KeyAuto,%ClearValue)
  495.     SET(%Key,%Key)
  496.         #IF(%ClearValue=1)
  497.     PREVIOUS(%File)
  498.         #ELSE
  499.     NEXT(%File)
  500.         #ENDIF
  501.         #FOR(%KeyField)
  502.           #IF(%KeyField=%KeyAuto)
  503.             #BREAK
  504.           #ENDIF
  505.         #ENDFOR
  506.     IF ERRORCODE() AND ERRORCODE() <> BadRecErr
  507.       StandardWarning(Warn:RecordFetchError,'%File')
  508.       POST(Event:CloseWindow)
  509.       EXIT
  510.     END
  511.         #IF(ITEMS(%KeyField) = 1)
  512.     IF ERRORCODE()
  513.         #ELSE
  514.     IF ERRORCODE() |
  515.         #ENDIF
  516.         #FOR(%KeyField),WHERE(%KeyField <> %KeyAuto)
  517.           #IF(INSTANCE(%KeyField) = ITEMS(%KeyField) - 1)
  518.     OR Auto::Save:%KeyField <> %KeyField
  519.           #ELSE
  520.     OR Auto::Save:%KeyField <> %KeyField |
  521.           #ENDIF
  522.         #ENDFOR
  523.       Auto::Save:%KeyAuto = 1
  524.     ELSE
  525.       Auto::Save:%KeyAuto = %KeyAuto + 1
  526.     END
  527.       #ELSE
  528.     SET(%Key)
  529.         #FOR(%KeyField)
  530.           #IF(%KeyFieldSequence = 'ASCENDING')
  531.     PREVIOUS(%File)
  532.           #ELSE
  533.     NEXT(%File)
  534.           #ENDIF
  535.         #ENDFOR
  536.     IF ERRORCODE() AND ERRORCODE() <> BadRecErr
  537.       StandardWarning(Warn:RecordFetchError,'%File')
  538.       POST(Event:CloseWindow)
  539.       EXIT
  540.     END
  541.     IF ERRORCODE()
  542.       Auto::Save:%KeyAuto = 1
  543.     ELSE
  544.       Auto::Save:%KeyAuto = %KeyAuto + 1
  545.     END
  546.       #ENDIF
  547.     #INSERT(%SaveButtonRecordHandler,'RESET',%Primary)
  548.     %KeyAuto = Auto::Save:%KeyAuto
  549.     #INSERT(%SaveButtonRecordHandler,'SET',%Primary)
  550.     #ENDFOR
  551.     ADD(%Primary)
  552.     IF ERRORCODE()
  553.       Auto::Attempts += 1
  554.       IF Auto::Attempts = 3
  555.         IF StandardWarning(Warn:AutoIncError) = Button:Retry
  556.           Auto::Attempts = 0
  557.         ELSE
  558.           LocalResponse = RequestCancelled
  559.           POST(Event:CloseWindow)
  560.           EXIT
  561.         END
  562.       END
  563.       CYCLE
  564.     END
  565.     BREAK
  566.   END
  567.   #ENDIF
  568. #ENDAT
  569. #!----------------------------------------------------------------
  570. #GROUP(%SaveButtonRecordHandlingGather,%CurrentFile)
  571. #FIX(%HandledFile,%CurrentFile)
  572. #IF(%HandledFile=%Null)
  573.   #FIX(%File,%CurrentFile)
  574.   #ADD(%HandledFile,%CurrentFile)
  575.   #ADD(%ProcFilesUsed,%CurrentFile)
  576.   #SET(%InsertAction,'NORMAL')
  577.   #FOR(%Key),WHERE(%KeyAuto)
  578.     #SET(%InsertAction,'AUTO')
  579.     #BREAK
  580.   #ENDFOR
  581.   #FOR(%Relation),WHERE(%FileRelationType='1:1')
  582.     #INSERT(%SaveButtonRecordHandlingGather,%CurrentFile)
  583.   #ENDFOR
  584. #ENDIF
  585. #!----------------------------------------------------------------
  586. #GROUP(%SaveButtonRecordHandler,%CurrentSection,%CurrentFile)
  587. #FIX(%File,%HandledFile)
  588. #SET(%ValueConstruct,'SAV::' & %FilePrefix & ':Record')
  589. #CASE(%CurrentSection)
  590. #OF('DECLARE')
  591.   #IF(NOT(%FirstHandledValue))
  592.     #SET(%FirstHandledValue,%ValueConstruct)
  593.   #ENDIF
  594.   #SET(%LastHandledValue,%ValueConstruct)
  595. %[20]ValueConstruct STRING(SIZE(%FilePrefix:Record))
  596. #OF('SET')
  597. %ValueConstruct = %FilePrefix:Record
  598. #OF('RESET')
  599. %FilePrefix:Record = %ValueConstruct
  600. #OF('CHECK')
  601. #IF(%ValueConstruct = %FirstHandledValue)
  602.   #IF(%ValueConstruct = %LastHandledValue)
  603. IF %ValueConstruct <> %FilePrefix:Record
  604.   RecordChanged = True
  605. END
  606.   #ELSE
  607. IF %ValueConstruct <> %FilePrefix:Record |
  608.   #ENDIF
  609. #ELSE
  610.   #IF(%ValueConstruct = %LastHandledValue)
  611. OR %ValueConstruct <> %FilePrefix:Record
  612.   RecordChanged = True
  613. END
  614.   #ELSE
  615. OR %ValueConstruct <> %FilePrefix:Record |
  616.   #ENDIF
  617. #ENDIF
  618. #ENDCASE
  619. #FOR(%Field),WHERE(%FieldType = 'MEMO')
  620.   #SET(%ValueConstruct,'SAV::' & %Field)
  621.   #CASE(%CurrentSection)
  622.   #OF('DECLARE')
  623. %[20]ValueConstruct STRING(SIZE(%Field))
  624.     #SET(%LastHandledValue,%ValueConstruct)
  625.   #OF('SET')
  626. %ValueConstruct = %Field
  627.   #OF('RESET')
  628. %Field = %ValueConstruct
  629.   #OF('CHECK')
  630.     #IF(%ValueConstruct = %LastHandledValue)
  631. OR %ValueConstruct <> %Field
  632.   RecordChanged = True
  633. END
  634.     #ELSE
  635. OR %ValueConstruct <> %Field |
  636.     #ENDIF
  637.   #ENDCASE
  638. #ENDFOR
  639. #!----------------------------------------------------------------
  640. #CONTROL(DOSFileLookup,'Lookup a DOS file name'),WINDOW,HLP('~TPLControlDOSFileLookup')
  641.                      CONTROLS
  642.                        BUTTON('...'),AT(,,12,12),USE(?LookupFile)
  643.                      END
  644. #BOXED('DOS File Lookup Prompts')
  645.   #PROMPT('File Dialog Header:',@S60),%DOSFileDialogHeader,REQ,DEFAULT('Choose a File')
  646.   #PROMPT('DOS FileName Variable:',FIELD),%DOSFileField,REQ
  647.   #PROMPT('Default Directory:',@S80),%DOSInitialDirectory
  648.   #PROMPT('Variable File Mask',CHECK),%DOSVariableMask
  649.   #ENABLE(%DOSVariableMask)
  650.     #PROMPT('Variable Mask Value:',FIELD),%DOSVariableMaskValue
  651.   #ENDENABLE
  652.   #ENABLE(NOT %DOSVariableMask)
  653.     #PROMPT('File Mask Description:',@S40),%DOSMaskDesc,REQ,DEFAULT('All Files')
  654.     #PROMPT('File Mask',@S50),%DOSMask,REQ,DEFAULT('*.*')
  655.     #BUTTON('More File Masks'),MULTI(%DOSMoreMasks,%DOSMoreMaskDesc & ' - ' & %DOSMoreMask)
  656.       #PROMPT('File Mask Description:',@S40),%DOSMoreMaskDesc,REQ
  657.       #PROMPT('File Mask',@S50),%DOSMoreMask,REQ
  658.     #ENDBUTTON
  659.   #ENDENABLE
  660. #ENDBOXED
  661. #LOCALDATA
  662. DOSDialogHeader      CSTRING(40)
  663. DOSExtParameter      CSTRING(250)
  664. DOSTargetVariable    CSTRING(80)
  665. #ENDLOCALDATA
  666. #ATSTART
  667.   #DECLARE(%DOSExtensionParameter)
  668.   #DECLARE(%DOSLookupControl)
  669.   #FOR(%Control),WHERE(%ControlInstance = %ActiveTemplateInstance)
  670.     #SET(%DOSLookupControl,%Control)
  671.   #ENDFOR
  672.   #IF(%DOSVariableMask)
  673.     #SET(%DOSExtensionParameter,%DOSVariableMask)
  674.   #ELSE
  675.     #SET(%DOSExtensionParameter,%DOSMaskDesc & '|' & %DOSMask)
  676.     #FOR(%DOSMoreMasks)
  677.       #SET(%DOSExtensionParameter,%DOSExtensionParameter & '|' & %DOSMoreMaskDesc & '|' & %DOSMoreMask)
  678.     #ENDFOR
  679.   #END
  680. #ENDAT
  681. #AT(%ControlEventHandling,%DOSLookupControl,'Accepted')
  682. IF NOT %DOSFileField
  683.   #INSERT(%StandardValueAssignment,'DOSTargetVariable',%DOSInitialDirectory)
  684. ELSE
  685.   DOSTargetVariable = %DOSFileField
  686. END
  687. #INSERT(%StandardValueAssignment,'DOSDialogHeader',%DOSFileDialogHeader)
  688. #INSERT(%StandardValueAssignment,'DOSExtParameter',%DOSExtensionParameter)
  689. IF FILEDIALOG(DOSDialogHeader,DOSTargetVariable,DOSExtParameter,0)
  690.   %DOSFileField = DOSTargetVariable
  691.   DO RefreshWindow
  692. END
  693. #ENDAT
  694. #!----------------------------------------------------------------
  695. #CONTROL(FileDrop,'File-Loaded Drop Box'),PRIMARY('File Loaded Drop Box',OPTKEY),DESCRIPTION('File Loaded Drop Box on ' & %Primary),WINDOW,MULTI,HLP('~TPLControlFileDrop')
  696.    CONTROLS
  697.      LIST,DROP(5),FROM(Queue:FileDrop)
  698.    END
  699. #BUTTON('File Drop Properties')
  700.   #SHEET
  701.     #TAB('&General'),HLP('~TPLControlFileDrop_General')
  702.       #PROMPT('Field to &fill from:',FIELD(%Primary)),%FillField,PROMPTAT(,30)
  703.       #PROMPT('&Target field:',FIELD),%TargetField
  704.       #PROMPT('&Record filter:',@S255),%RecordFilter
  705.       #PROMPT('Default to first entry if USE variable empty',CHECK),%DefaultFill,AT(10,,180)
  706.     #ENDTAB
  707.     #TAB('&Range Limits'),WHERE(%PrimaryKey),HLP('~TPLControlFileDrop_Range_Limits')
  708.       #PROMPT('Range limit &field:',COMPONENT(%PrimaryKey)),%RangeField,PROMPTAT(,30)
  709.       #ENABLE(%RangeField)
  710.         #PROMPT('Range limit &type:',DROP('Current Value|Single Value|Range of Values|File Relationship')),%RangeLimitType,DEFAULT('Current Value')
  711.         #BOXED('Range limit boundary'),WHERE(%RangeLimitType='Single Value'),AT(,55)
  712.           #PROMPT('&Range limit value:',FIELD),%RangeLimit
  713.         #ENDBOXED
  714.         #BOXED('Range limit boundaries'),WHERE(%RangeLimitType='Range of Values'),AT(,55)
  715.           #PROMPT('&Low limit value:',FIELD),%RangeLow
  716.           #PROMPT('&High limit value:',FIELD),%RangeHigh
  717.         #ENDBOXED
  718.         #BOXED('Range limiting file'),WHERE(%RangeLimitType='File Relationship'),AT(,55)
  719.           #PROMPT('&Related file:',FILE),%RangeFile
  720.         #ENDBOXED
  721.       #ENDENABLE
  722.     #ENDTAB
  723.     #TAB('&Colors'),WHERE(%ControlHasColor),HLP('~TPLControlFileDrop_Colors')
  724.       #PREPARE
  725.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  726.       #ENDPREPARE
  727.       #BUTTON('Customize Colors'),FROM(%ControlField,%ControlField),AT(,30),HLP('~TPLControlBrowseBox'),INLINE,WHERE(%ControlFieldHasColor)
  728.         #PREPARE
  729.           #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  730.         #ENDPREPARE
  731.         #BOXED('Default Colors')
  732.           #PROMPT('&Foreground Normal:',COLOR),%ControlFieldForegroundNormal,DEFAULT(-1)
  733.           #PROMPT('&Background Normal:',COLOR),%ControlFieldBackgroundNormal,DEFAULT(-1)
  734.           #PROMPT('&Foreground Selected:',COLOR),%ControlFieldForegroundSelected,DEFAULT(-1)
  735.           #PROMPT('&Background Selected:',COLOR),%ControlFieldBackgroundSelected,DEFAULT(-1)
  736.         #ENDBOXED
  737.         #BOXED('Conditional Color Assignments')
  738.           #BUTTON('Conditional Color Assignments'),MULTI(%ConditionalColors,%ColorCondition),INLINE,HLP('~TPLControlFileDrop_Colors')
  739.             #PROMPT('&Condition:',@S255),%ColorCondition
  740.             #PROMPT('&Foreground Normal:',COLOR),%ConditionalControlFieldForegroundNormal,DEFAULT(-1)
  741.             #PROMPT('&Background Normal:',COLOR),%ConditionalControlFieldBackgroundNormal,DEFAULT(-1)
  742.             #PROMPT('&Foreground Selected:',COLOR),%ConditionalControlFieldForegroundSelected,DEFAULT(-1)
  743.             #PROMPT('&Background Selected:',COLOR),%ConditionalControlFieldBackgroundSelected,DEFAULT(-1)
  744.           #ENDBUTTON
  745.         #ENDBOXED
  746.       #ENDBUTTON
  747.     #ENDTAB
  748.     #TAB('&Icons'),WHERE(%ControlHasIcon),HLP('~TPLControlFileDrop_Icons')
  749.       #PREPARE
  750.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  751.       #ENDPREPARE
  752.       #BUTTON('&Customize BrowseBox Icons'),FROM(%ControlField,%ControlField & ' - ' & %ControlFieldIcon),AT(,30),HLP('~TPLControlBrowseBox'),INLINE,WHERE(%ControlFieldHasIcon)
  753.         #PREPARE
  754.           #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  755.         #ENDPREPARE
  756.         #BOXED('Default Icon')
  757.           #PROMPT('Icon:',@S40),%ControlFieldIcon
  758.         #ENDBOXED
  759.         #BOXED('Conditional Icon Usage')
  760.           #BUTTON('&Conditional Icon Usage'),MULTI(%ConditionalIcons,%IconCondition),INLINE,HLP('~TPLControlFileDrop_Icons')
  761.             #PROMPT('&Condition:',@S255),%IconCondition
  762.             #PROMPT('Icon:',@S40),%ConditionalControlFieldIcon
  763.           #ENDBUTTON
  764.         #ENDBOXED
  765.       #ENDBUTTON
  766.     #ENDTAB
  767.     #TAB('&Hot Fields'),HLP('~TPLControlFileDrop_Hot_Fields')
  768.       #BUTTON('Hot fields'),MULTI(%HotFields,%HotField),INLINE,AT(,30)
  769.         #PROMPT('&Hot field:',FIELD),%HotField
  770.         #PROMPT('&BIND field',CHECK),%HotFieldBound
  771.       #ENDBUTTON
  772.     #ENDTAB
  773.     #TAB('&Sort Fields'),HLP('~TPLControlFileDrop_Sort_Fields')
  774.       #BUTTON('Sort fields'),MULTI(%SortFields,%SortField),INLINE,AT(,30)
  775.         #PROMPT('Sort &field:',FIELD),%SortField
  776.       #ENDBUTTON
  777.     #ENDTAB
  778.   #ENDSHEET
  779. #ENDBUTTON
  780. #AT(%CustomGlobalDeclarations)
  781.   #INSERT(%FileControlSetFlags)
  782. #ENDAT
  783. #ATSTART
  784.   #DECLARE(%ListViewBoundField),UNIQUE
  785.   #INSERT(%FileDropStartInitialize)
  786. #ENDAT
  787. #AT(%DataSectionBeforeWindow)
  788. #INSERT(%FileDropDataSection)
  789. #ENDAT
  790. #AT(%WindowEventHandling,'OpenWindow')
  791. #INSERT(%FileDropWindowOpen)
  792. #ENDAT
  793. #AT(%ControlEventHandling,%DropControl,'Accepted')
  794.   #IF(%TargetField)
  795. GET(%DropQueue,CHOICE())
  796. %TargetField = %ValueName
  797.   #ENDIF
  798. #ENDAT
  799. #AT(%ProcedureRoutines)
  800.   #FIX(%Control,%DropControl)
  801.  
  802. %InstancePrefix:FillList ROUTINE
  803.   FREE(%DropQueue)
  804.   #IF(%OldStyleFileDrop)
  805.     #IF ( %FillField = %FirstDropField )
  806.   %InstancePrefix:%FirstDropField = %ControlUse
  807.     #ENDIF
  808.   %Control{Prop:From} = %DropQueue
  809.     #IF ( %FillField = %FirstDropField )
  810.   %ControlUse = %InstancePrefix:%FirstDropField
  811.     #ENDIF
  812.   #ENDIF
  813.   #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,%InstancePrefix & ':Save:',%Temp1,%Temp2,'Save')
  814.   SET(%LoadOrder)
  815.   #IF ( %DropViewFilter )
  816.   %ListView{Prop:Filter} = '%'DropViewFilter'
  817.   #ENDIF
  818.   OPEN(%ListView)
  819.   LOOP
  820.   #INSERT(%QueueFillLoop)
  821.     ADD(%DropQueue)
  822.   END
  823.   CLOSE(%ListView)
  824.   IF RECORDS(%DropQueue)
  825.   #IF(ITEMS(%SortFields))
  826.     #DECLARE(%SortList)
  827.     #SET(%SortList,'')
  828.     #FOR(%SortFields)
  829.       #IF(%SortList )
  830.         #SET(%SortList,%SortList & ',')
  831.       #ENDIF
  832.       #SET(%SortList,%SortList & %InstancePrefix & ':' & %SortField)
  833.     #ENDFOR
  834.     SORT(%DropQueue,%SortList)
  835.   #ELSE
  836.     #IF (NOT %PrimaryKey)
  837.     SORT(%DropQueue,%ValueName)
  838.     #ENDIF
  839.   #ENDIF
  840.     IF %ControlUse
  841.       LOOP %InstancePrefix:LoopIndex = 1 TO RECORDS(%DropQueue)
  842.         GET(%DropQueue,%InstancePrefix:LoopIndex)
  843.         IF %ControlUse = %InstancePrefix:%FirstDropField THEN BREAK.
  844.       END
  845.       %Control{Prop:Selected} = %InstancePrefix:LoopIndex
  846.   #IF(%DefaultFill)
  847.     ELSE
  848.       GET(%DropQueue,1)
  849.       %ControlUse = %InstancePrefix:%FirstDropField
  850.       %Control{Prop:Selected} = 1
  851.   #ENDIF
  852.     END
  853.   ELSE
  854.     CLEAR(%ControlUse)
  855.   END
  856. #ENDAT
  857. #GROUP (%FileDropWindowOpen)
  858.   #FOR(%ListViewBoundField)
  859.     #FIND(%Field,%ListViewBoundField)
  860.     #IF(NOT %FieldFile OR %FieldName)
  861. BIND('%ListViewBoundField',%ListViewBoundField)
  862.     #ENDIF
  863.   #ENDFOR
  864. #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,%InstancePrefix & ':Save:',%Temp1,%Temp2,'Bind')
  865.   #FOR(%IconList),WHERE(%IconListType <> 'Variable')
  866.     #SET(%ValueConstruct,INSTANCE(%IconList))
  867.     #IF(%IconListType = 'Built-In')
  868. %DropControl{Prop:IconList,%ValueConstruct} = %IconList
  869.     #ELSIF(%IconListType = 'File')
  870. %DropControl{Prop:IconList,%ValueConstruct} = '%IconList'
  871.     #ENDIF
  872.   #ENDFOR
  873. DO %InstancePrefix:FillList
  874. #GROUP (%QueueFillLoop)
  875.   NEXT(%ListView)
  876.   IF ERRORCODE()
  877.     IF ERRORCODE() = BadRecErr
  878.       BREAK
  879.     ELSE
  880.       StandardWarning(Warn:RecordFetchError,'%Primary')
  881.       POST(Event:CloseWindow)
  882.       EXIT
  883.     END
  884.   END
  885.   #FOR (%QueueField)
  886.     #FIX(%ControlField,%QueueFieldAssignment)
  887.     #IF (%ControlField)
  888.   %QueueField = %QueueFieldAssignment
  889.       #IF (%ControlFieldHasColor)
  890.         #IF(ITEMS(%ConditionalColors))
  891.           #FOR(%ConditionalColors)
  892.             #IF(INSTANCE(%ConditionalColors) = 1)
  893.   IF (%ColorCondition)
  894.             #ELSE
  895.   ELSIF (%ColorCondition)
  896.             #ENDIF
  897.     %QueueField:NormalFG = %ConditionalControlFieldForegroundNormal
  898.     %QueueField:NormalBG = %ConditionalControlFieldBackgroundNormal
  899.     %QueueField:SelectedFG = %ConditionalControlFieldForegroundSelected
  900.     %QueueField:SelectedBG = %ConditionalControlFieldBackgroundSelected
  901.           #ENDFOR
  902.   ELSE
  903.     %QueueField:NormalFG = %ControlFieldForegroundNormal
  904.     %QueueField:NormalBG = %ControlFieldBackgroundNormal
  905.     %QueueField:SelectedFG = %ControlFieldForegroundSelected
  906.     %QueueField:SelectedBG = %ControlFieldBackgroundSelected
  907.   END
  908.         #ELSE
  909.   %QueueField:NormalFG = %ControlFieldForegroundNormal
  910.   %QueueField:NormalBG = %ControlFieldBackgroundNormal
  911.   %QueueField:SelectedFG = %ControlFieldForegroundSelected
  912.   %QueueField:SelectedBG = %ControlFieldBackgroundSelected
  913.         #ENDIF
  914.       #ENDIF
  915.       #IF (%ControlFieldHasIcon)
  916.         #IF(ITEMS(%ConditionalIcons))
  917.           #FOR(%ConditionalIcons)
  918.             #IF(INSTANCE(%ConditionalIcons) = 1)
  919.   IF (%IconCondition)
  920.             #ELSE
  921.   ELSIF (%IconCondition)
  922.             #ENDIF
  923.             #FIX(%IconList,%ConditionalControlFieldIcon)
  924.             #IF(%IconList)
  925.               #CASE(%IconListType)
  926.               #OF('Variable')
  927.     %QueueField:Icon = %IconList
  928.               #ELSE
  929.                 #SET(%ValueConstruct,INSTANCE(%IconList))
  930.     %QueueField:Icon = %ValueConstruct
  931.               #ENDCASE
  932.             #ELSE
  933.     %QueueField:Icon = 0
  934.             #ENDIF
  935.           #ENDFOR
  936.   ELSE
  937.           #FIX(%IconList,%ControlFieldIcon)
  938.           #IF(%IconList)
  939.             #CASE(%IconListType)
  940.             #OF('Variable')
  941.     %QueueField:Icon = %IconList
  942.             #ELSE
  943.               #SET(%ValueConstruct,INSTANCE(%IconList))
  944.     %QueueField:Icon = %ValueConstruct
  945.             #ENDCASE
  946.           #ELSE
  947.     %QueueField:Icon = 0
  948.           #ENDIF
  949.   END
  950.         #ELSE
  951.           #FIX(%IconList,%ControlFieldIcon)
  952.           #IF(%IconList)
  953.             #CASE(%IconListType)
  954.             #OF('Variable')
  955.     %QueueField:Icon = %IconList
  956.             #ELSE
  957.               #SET(%ValueConstruct,INSTANCE(%IconList))
  958.     %QueueField:Icon = %ValueConstruct
  959.             #ENDCASE
  960.           #ELSE
  961.     %QueueField:Icon = 0
  962.           #ENDIF
  963.         #ENDIF
  964.       #ENDIF
  965.     #ELSE
  966.       #FIND(%Field,%QueueFieldAssignment)
  967.       #IF (%Field)
  968.   %QueueField = %QueueFieldAssignment
  969.       #ENDIF
  970.     #ENDIF
  971.   #ENDFOR
  972.   #IF ( %FillField <> %FirstDropField AND %TargetField )
  973.   IF ~%ControlUse AND %TargetField = %InstancePrefix:%FillField THEN
  974.     %ControlUse = %InstancePrefix:%FirstDropField
  975.   END
  976.   #ENDIF
  977. #! A file loaded drop combo box
  978. #! Combo may only have one populated field
  979. #! Target field may either be same as populated or different
  980. #! In absence of use value call up form (optionally)
  981. #CONTROL(FileDropCombo,'File-Loaded Drop Combo'),PRIMARY('File Loaded Drop Combo',OPTKEY),DESCRIPTION('File Loaded Drop Combo on ' & %Primary),WINDOW,MULTI,HLP('~TPLControlFileDropCombo')
  982.    CONTROLS
  983.      COMBO(@s20),DROP(5),FROM(Queue:FileDropCombo)
  984.    END
  985. #BUTTON('File Drop Combo Properties')
  986.   #SHEET
  987.     #TAB('&General'),HLP('~TPLControlFileDropCombo_General')
  988.       #PROMPT('Field to &fill from:',FIELD(%Primary)),%FillField,PROMPTAT(,30)
  989.       #PROMPT('&Target field:',FIELD),%TargetField
  990.       #PROMPT('&Record filter:',@S255),%RecordFilter
  991.       #PROMPT('R&emove duplicate entries',CHECK),%RemoveDuplicates,AT(10,,180)
  992.       #PROMPT('Default to first entry if USE variable empty',CHECK),%DefaultFill,AT(10,,180)
  993.     #ENDTAB
  994.     #TAB('&Range Limits'),WHERE(%PrimaryKey),HLP('~TPLControlFileDropCombo_Range_Limits')
  995.       #PROMPT('Range limit &field:',COMPONENT(%PrimaryKey)),%RangeField,PROMPTAT(,30)
  996.       #ENABLE(%RangeField)
  997.         #PROMPT('Range limit &type:',DROP('Current Value|Single Value|Range of Values|File Relationship')),%RangeLimitType,DEFAULT('Current Value')
  998.         #BOXED('Range limit boundary'),WHERE(%RangeLimitType='Single Value'),AT(,55)
  999.           #PROMPT('&Range limit value:',FIELD),%RangeLimit
  1000.         #ENDBOXED
  1001.         #BOXED('Range limit boundaries'),WHERE(%RangeLimitType='Range of Values'),AT(,55)
  1002.           #PROMPT('&Low limit value:',FIELD),%RangeLow
  1003.           #PROMPT('&High limit value:',FIELD),%RangeHigh
  1004.         #ENDBOXED
  1005.         #BOXED('Range limiting file'),WHERE(%RangeLimitType='File Relationship'),AT(,55)
  1006.           #PROMPT('&Related file:',FILE),%RangeFile
  1007.         #ENDBOXED
  1008.       #ENDENABLE
  1009.     #ENDTAB
  1010.     #TAB('&Colors'),WHERE(%ControlHasColor),HLP('~TPLControlFileDropCombo_Colors')
  1011.       #PREPARE
  1012.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  1013.       #ENDPREPARE
  1014.       #BUTTON('Customize Colors'),FROM(%ControlField,%ControlField),AT(,30),HLP('~TPLControlBrowseBox'),INLINE,WHERE(%ControlFieldHasColor)
  1015.         #PREPARE
  1016.           #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  1017.         #ENDPREPARE
  1018.         #BOXED('Default Colors')
  1019.           #PROMPT('&Foreground Normal:',COLOR),%ControlFieldForegroundNormal,DEFAULT(-1)
  1020.           #PROMPT('&Background Normal:',COLOR),%ControlFieldBackgroundNormal,DEFAULT(-1)
  1021.           #PROMPT('&Foreground Selected:',COLOR),%ControlFieldForegroundSelected,DEFAULT(-1)
  1022.           #PROMPT('&Background Selected:',COLOR),%ControlFieldBackgroundSelected,DEFAULT(-1)
  1023.         #ENDBOXED
  1024.         #BOXED('Conditional Color Assignments')
  1025.           #BUTTON('Conditional Color Assignments'),MULTI(%ConditionalColors,%ColorCondition),INLINE,HLP('~TPLControlFileDropCombo_Colors')
  1026.             #PROMPT('&Condition:',@S255),%ColorCondition
  1027.             #PROMPT('&Foreground Normal:',COLOR),%ConditionalControlFieldForegroundNormal,DEFAULT(-1)
  1028.             #PROMPT('&Background Normal:',COLOR),%ConditionalControlFieldBackgroundNormal,DEFAULT(-1)
  1029.             #PROMPT('&Foreground Selected:',COLOR),%ConditionalControlFieldForegroundSelected,DEFAULT(-1)
  1030.             #PROMPT('&Background Selected:',COLOR),%ConditionalControlFieldBackgroundSelected,DEFAULT(-1)
  1031.           #ENDBUTTON
  1032.         #ENDBOXED
  1033.       #ENDBUTTON
  1034.     #ENDTAB
  1035.     #TAB('&Icons'),WHERE(%ControlHasIcon),HLP('~TPLControlFileDropCombo_Icons')
  1036.       #PREPARE
  1037.         #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  1038.       #ENDPREPARE
  1039.       #BUTTON('&Customize BrowseBox Icons'),FROM(%ControlField,%ControlField & ' - ' & %ControlFieldIcon),AT(,30),INLINE,WHERE(%ControlFieldHasIcon),HLP('~TPLControlFileDropCombo_Icons')
  1040.         #PREPARE
  1041.           #FIND(%ControlInstance,%ActiveTemplateInstance,%Control)
  1042.         #ENDPREPARE
  1043.         #BOXED('Default Icon')
  1044.           #PROMPT('Icon:',@S40),%ControlFieldIcon
  1045.         #ENDBOXED
  1046.         #BOXED('Conditional Icon Usage')
  1047.           #BUTTON('&Conditional Icon Usage'),MULTI(%ConditionalIcons,%IconCondition),INLINE,HLP('~TPLControlFileDropCombo_Icons')
  1048.             #PROMPT('&Condition:',@S255),%IconCondition
  1049.             #PROMPT('Icon:',@S40),%ConditionalControlFieldIcon
  1050.           #ENDBUTTON
  1051.         #ENDBOXED
  1052.       #ENDBUTTON
  1053.     #ENDTAB
  1054.     #TAB('&Update Behavior'),HLP('~TPLControlFileDropCombo_Update_Behavior')
  1055.       #PROMPT('&Allow updates',CHECK),%AllowUpdate,AT(,30)
  1056.       #ENABLE(%AllowUpdate)
  1057.         #PROMPT('&Update procedure:',PROCEDURE),%UpdateProcedure
  1058.         #PROMPT('Prompt &caption:',@s80),%PromptCaption,DEFAULT('Record not found')
  1059.         #PROMPT('&Prompt text:',@s80),%PromptText,DEFAULT('Add new record?')
  1060.       #ENDENABLE
  1061.     #ENDTAB
  1062.     #TAB('&Hot Fields'),HLP('~TPLControlFileDropCombo_Hot_Fields')
  1063.       #BUTTON('Hot Fields'),MULTI(%HotFields,%HotField),INLINE,AT(,30)
  1064.         #PROMPT('&Hot field:',FIELD),%HotField
  1065.         #PROMPT('&BIND field',CHECK),%HotFieldBound
  1066.       #ENDBUTTON
  1067.     #ENDTAB
  1068.   #ENDSHEET
  1069. #ENDBUTTON
  1070. #AT(%CustomGlobalDeclarations)
  1071.   #INSERT(%FileControlSetFlags)
  1072. #ENDAT
  1073. #ATSTART
  1074.   #DECLARE(%ListViewBoundField),UNIQUE
  1075.   #DECLARE(%SortFields),MULTI
  1076.   #FREE(%SortFields)
  1077.   #INSERT(%FileDropStartInitialize)
  1078. #ENDAT
  1079.  
  1080. #AT(%DataSectionBeforeWindow)
  1081. #INSERT(%FileDropDataSection)
  1082. #ENDAT
  1083.  
  1084. #AT(%WindowEventHandling,'OpenWindow')
  1085. #INSERT(%FileDropWindowOpen)
  1086. #ENDAT
  1087. #AT(%ControlEventHandling,%DropControl,'Accepted')
  1088.   #FIX(%Control,%DropControl)
  1089. %InstancePrefix:%FirstDropField = %ControlUse
  1090. GET(%DropQueue,%InstancePrefix:%FirstDropField)
  1091. IF ERRORCODE() THEN
  1092.   #IF (%AllowUpdate)
  1093.     #IF (%PromptCaption OR %PromptText)
  1094.   IF MESSAGE('%PromptText','%PromptCaption',ICON:Question,BUTTON:Yes+BUTTON:No) <> BUTTON:Yes THEN
  1095.     SELECT(%DropControl)
  1096.     CYCLE
  1097.   END
  1098.     #ENDIF
  1099.   GET(%Primary,0)
  1100.     #FIX(%File,%Primary)
  1101.   CLEAR(%FilePrefix:Record)
  1102.     #FOR(%Field),WHERE(%FieldType = 'MEMO')
  1103.   CLEAR(%Field)
  1104.     #ENDFOR
  1105.     #FOR(%Field),WHERE(%FieldType = 'BLOB')
  1106.   %Field{Prop:Size} = 0
  1107.     #ENDFOR
  1108.     #FIX(%Control,%DropControl)
  1109.   %FirstDropField = %ControlUse
  1110.     #IF ( %RangeLimit )
  1111.   %RangeField = %RangeLimit
  1112.     #ENDIF
  1113.     #IF (%UpdateProcedure)
  1114.   LocalRequest = InsertRecord
  1115.   GlobalRequest = LocalRequest
  1116.   %UpdateProcedure
  1117.   LocalResponse = GlobalResponse
  1118.   IF LocalResponse = RequestCompleted THEN
  1119.     DO %InstancePrefix:FillList
  1120.     POST(Event:Accepted,%DropControl)
  1121.   ELSE
  1122.     SELECT(%DropControl)
  1123.   END
  1124.     #ELSE
  1125.       #FIX(%File,%Primary)
  1126.       #FOR (%Relation), WHERE(%FileRelationType = 'MANY:1')
  1127.         #ERROR('Unable to handle MANY:1 related files')
  1128.       #ENDFOR
  1129.       #FOR (%Key), WHERE(%KeyExcludeNulls)
  1130.         #FOR (%KeyField)
  1131.           #IF ( %KeyField <> %FirstDropField AND %KeyField <> %RangeLimit )
  1132.             #ERROR('Unable to fill all non-null field:'&%KeyField)
  1133.           #ENDIF
  1134.         #ENDFOR
  1135.       #ENDFOR
  1136.       #FOR (%Key), WHERE(%KeyAuto)
  1137.         #ERROR('Unable to handle auto-increment key'&%Key)
  1138.       #ENDFOR
  1139.   ADD(%Primary)
  1140.   IF ~ERRORCODE() THEN
  1141.     DO %InstancePrefix:FillList
  1142.     POST(Event:Accepted,%DropControl)
  1143.   ELSE
  1144.     SELECT(%DropControl)
  1145.   END
  1146.     #ENDIF
  1147.   #ELSE
  1148.   SELECT(%DropControl)
  1149.   #ENDIF
  1150.   #IF ( %TargetField )
  1151. ELSE
  1152.   %TargetField = %ValueName
  1153.   #ENDIF
  1154. END
  1155. #ENDAT
  1156. #AT(%ProcedureRoutines)
  1157.   #FIX(%Control,%DropControl)
  1158. %InstancePrefix:FillList ROUTINE
  1159.   FREE(%DropQueue)
  1160.   #IF ( %FillField = %FirstDropField )
  1161.   %InstancePrefix:%FirstDropField = %ControlUse
  1162.   #ENDIF
  1163.   #IF ( %FillField = %FirstDropField )
  1164.   %ControlUse = %InstancePrefix:%FirstDropField
  1165.   #ENDIF
  1166.   #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,%InstancePrefix & ':Save:',%Temp1,%Temp2,'Save')
  1167.   SET(%LoadOrder)
  1168.   #IF ( %DropViewFilter )
  1169.   %ListView{Prop:Filter} = '%'DropViewFilter'
  1170.   #ENDIF
  1171.   OPEN(%ListView)
  1172.   LOOP
  1173.   #INSERT(%QueueFillLoop)
  1174.   #IF (%RemoveDuplicates)
  1175.     GET(%DropQueue,%InstancePrefix:%FirstDropField)
  1176.     IF ERRORCODE() THEN
  1177.       ADD(%DropQueue,%InstancePrefix:%FirstDropField)
  1178.     END
  1179.   #ELSE
  1180.     ADD(%DropQueue)
  1181.   #ENDIF
  1182.   END
  1183.   CLOSE(%ListView)
  1184.   IF RECORDS(%DropQueue)
  1185.     SORT(%DropQueue,%InstancePrefix:%FirstDropField)
  1186.     IF %ControlUse
  1187.       LOOP %InstancePrefix:LoopIndex = 1 TO RECORDS(%DropQueue)
  1188.         GET(%DropQueue,%InstancePrefix:LoopIndex)
  1189.         IF %ControlUse = %InstancePrefix:%FirstDropField THEN BREAK.
  1190.       END
  1191.       %Control{Prop:Selected} = %InstancePrefix:LoopIndex
  1192.   #IF(%DefaultFill)
  1193.     ELSE
  1194.       GET(%DropQueue,1)
  1195.       %ControlUse = %InstancePrefix:%FirstDropField
  1196.       %Control{Prop:Selected} = 1
  1197.   #ENDIF
  1198.     END
  1199.   ELSE
  1200.     CLEAR(%ControlUse)
  1201.   END
  1202. #ENDAT
  1203. #GROUP(%FileDropStartInitialize)
  1204.   #INSERT(%FileControlInitialize)
  1205.   #DECLARE(%DropControl)
  1206.   #DECLARE(%DropQueue)
  1207.   #DECLARE(%LoadOrder)
  1208.   #DECLARE(%ValueName)
  1209.   #DECLARE(%DropViewFilter)
  1210.   #DECLARE(%Temp1)
  1211.   #DECLARE(%Temp2)
  1212.   #CASE(%RangeLimitType)
  1213.   #OF('Range of Values')
  1214.     #SET(%Temp1,%RangeLow)
  1215.     #SET(%Temp2,%RangeHigh)
  1216.   #OF('Single Value')
  1217.     #SET(%Temp1,%RangeLimit)
  1218.   #OF('File Relationship')
  1219.     #SET(%Temp1,%RangeFile)
  1220.   #ENDCASE
  1221.   #FIX(%File,%Primary)
  1222.   #IF (%PrimaryKey)
  1223.     #SET(%LoadOrder,%PrimaryKey)
  1224.   #ELSE
  1225.     #SET(%LoadOrder,%File)
  1226.     #FOR(%Key),WHERE(%KeyPrimary)
  1227.       #SET(%LoadOrder,%Key)
  1228.     #ENDFOR
  1229.   #ENDIF
  1230.   #DECLARE(%InstancePrefix)
  1231.   #DECLARE(%OldStyleFileDrop)
  1232.   #SET(%InstancePrefix,'FLD' & %ActiveTemplateInstance & ':')
  1233.   #FOR(%Control),WHERE(%ControlInstance=%ActiveTemplateInstance)
  1234.     #SET(%DropControl,%Control)
  1235.     #SET(%ValueConstruct,EXTRACT(%ControlStatement,'FROM',1))
  1236.     #IF(INSTRING('|',%ValueConstruct,1,1))
  1237.       #SET(%DropQueue,%InstancePrefix & ':Queue')
  1238.       #SET(%OldStyleFileDrop,%True)
  1239.     #ELSE
  1240.       #SET(%DropQueue,%ValueConstruct)
  1241.       #SET(%OldStyleFileDrop,%False)
  1242.     #ENDIF
  1243.   #ENDFOR
  1244.   #DECLARE(%IconList),UNIQUE
  1245.   #DECLARE(%IconListType,%IconList)
  1246.   #DECLARE(%QueueField),MULTI
  1247.   #DECLARE(%QueueFieldAssignment,%QueueField)
  1248.   #DECLARE(%ListView)
  1249.   #DECLARE(%FillVisible,%False)
  1250.   #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,%InstancePrefix & ':Save:',%Temp1,%Temp2,'Construct')
  1251.   #SET(%DropViewFilter,%ValueConstruct)
  1252.   #SET(%ListView,%InstancePrefix & ':View')
  1253.   #SET(%ValueName,%InstancePrefix & ':' & %FillField)
  1254.   #FIX(%Control,%DropControl)
  1255.   #FOR(%ControlField),WHERE(%ControlField)
  1256.     #IF (%ControlField = %FillField)
  1257.       #SET(%FillVisible,%True)
  1258.     #ENDIF
  1259.     #SET(%ValueConstruct,%InstancePrefix & ':' & %ControlField)
  1260.     #IF (~%ValueName)
  1261.       #SET(%ValueName,%ValueConstruct)
  1262.     #ENDIF
  1263.     #ADD(%QueueField,%ValueConstruct)
  1264.     #SET(%QueueFieldAssignment,%ControlField)
  1265.     #IF(%ControlFieldHasColor)
  1266.       #ADD(%QueueField,%ValueConstruct&':NormalFG')
  1267.       #SET(%QueueFieldAssignment,-1)
  1268.       #ADD(%QueueField,%ValueConstruct&':NormalBG')
  1269.       #SET(%QueueFieldAssignment,-1)
  1270.       #ADD(%QueueField,%ValueConstruct&':SelectedFG')
  1271.       #SET(%QueueFieldAssignment,-1)
  1272.       #ADD(%QueueField,%ValueConstruct&':SelectedBG')
  1273.       #SET(%QueueFieldAssignment,-1)
  1274.     #ENDIF
  1275.     #IF(%ControlFieldHasIcon)
  1276.       #IF(%ControlFieldIcon)
  1277.         #INSERT(%AddBrowseIcon,%ControlFieldIcon)
  1278.         #FOR(%ConditionalIcons)
  1279.           #INSERT(%AddBrowseIcon,%ConditionalControlFieldIcon)
  1280.         #ENDFOR
  1281.       #ENDIF
  1282.       #ADD(%QueueField,%ValueConstruct&':Icon')
  1283.       #SET(%QueueFieldAssignment,0)
  1284.     #ENDIF
  1285.   #ENDFOR
  1286.   #IF (~%FillVisible)
  1287.     #ADD(%QueueField,%InstancePrefix & ':' & %FillField)
  1288.     #SET(%QueueFieldAssignment,%FillField)
  1289.   #ENDIF
  1290.   #FOR(%SortFields)
  1291.     #SET(%ValueConstruct,%InstancePrefix & ':' & %SortField)
  1292.     #IF ( NOT INLIST(%ValueConstruct,%QueueField) )
  1293.       #ADD(%QueueField,%ValueConstruct)
  1294.       #SET(%QueueFieldAssignment,%SortField)
  1295.     #ENDIF
  1296.   #ENDFOR
  1297.   #FOR(%HotFields)
  1298.     #SET(%ValueConstruct,%InstancePrefix & ':' & %HotField)
  1299.     #FIX(%QueueField,%ValueConstruct)
  1300.     #IF(%QueueField <> %ValueConstruct)
  1301.       #ADD(%QueueField,%ValueConstruct)
  1302.       #SET(%QueueFieldAssignment,%HotField)
  1303.     #ENDIF
  1304.     #IF ( %HotFieldBound )
  1305.       #ADD(%ListViewBoundField,%HotField)
  1306.     #ENDIF
  1307.   #ENDFOR
  1308.   #FIX(%File,%Primary)
  1309.   #FIX(%Key,%PrimaryKey)
  1310.   #FOR(%KeyField)
  1311.     #SET(%ValueConstruct,%InstancePrefix & ':' & %KeyField)
  1312.     #FIX(%QueueField,%ValueConstruct)
  1313.     #IF(%QueueField <> %ValueConstruct)
  1314.       #ADD(%QueueField,%ValueConstruct)
  1315.       #SET(%QueueFieldAssignment,%KeyField)
  1316.     #ENDIF
  1317.   #ENDFOR
  1318.   #FOR(%ListViewBoundField)
  1319.     #SET(%ValueConstruct,%InstancePrefix & ':' & %ListViewBoundField)
  1320.     #FIX(%QueueField,%ValueConstruct)
  1321.     #IF(%QueueField<>%ValueConstruct)
  1322.       #ADD(%QueueField,%ValueConstruct)
  1323.       #SET(%QueueFieldAssignment,%ListViewBoundField)
  1324.     #ENDIF
  1325.   #ENDFOR
  1326.   #IF ( ~%FillField )
  1327.     #FIX(%Control,%DropControl)
  1328.     #IF ( ITEMS(%ControlField) )
  1329.       #SELECT(%ControlField,1)
  1330.       #SET(%FillField,%ControlField)
  1331.     #ELSIF ( %ControlUse )
  1332.       #SET(%FillField,%ControlUse)
  1333.     #ENDIF
  1334.   #ENDIF
  1335.   #DECLARE(%FirstDropField)
  1336.   #FIX(%Control,%DropControl)
  1337.   #IF ( ITEMS(%ControlField) )
  1338.     #SELECT(%ControlField,1)
  1339.     #SET(%FirstDropField,%ControlField)
  1340.   #ELSE
  1341.     #SET(%FirstDropField,%FillField)
  1342.   #ENDIF
  1343. #!------------------------------------------------------------------------------
  1344. #GROUP(%FileDropDataSection)
  1345. #INSERT(%ConstructView)
  1346. %[20]DropQueue QUEUE,PRE
  1347. #FOR(%QueueField),WHERE(%QueueField)
  1348.   #FIND(%Field,%QueueFieldAssignment)
  1349.   #IF (%Field)
  1350. %[22]QueueField LIKE(%QueueFieldAssignment)
  1351.   #ELSE
  1352. %[22]QueueField LONG
  1353.   #ENDIF
  1354. #ENDFOR
  1355. %[20]Null END
  1356.     #SET(%ValueConstruct,%InstancePrefix & ':LoopIndex')
  1357. %[20]ValueConstruct LONG,AUTO
  1358. #INSERT(%StandardViewFilter,%RecordFilter,%PrimaryKey,%RangeField,%RangeLimitType,%InstancePrefix & ':Save:',%Temp1,%Temp2,'Declare')
  1359. #!----------------------------------------------------------------
  1360. #CONTROL(FieldLookupButton,'Trigger an Entry Control Lookup'),DESCRIPTION('Trigger an Entry Control Lookup'),WINDOW,MULTI,HLP('~TPLControlFieldLookupButton')
  1361.    CONTROLS
  1362.      BUTTON('...'),AT(,,12,12),USE(?CallLookup)
  1363.    END
  1364. #BOXED('Field Lookup Button Prompts')
  1365.   #PROMPT('Control with lookup:',CONTROL),%ControlToLookup
  1366. #ENDBOXED
  1367. #ATSTART
  1368.   #DECLARE(%LookupControl)
  1369.   #FOR(%Control),WHERE(%ControlInstance=%ActiveTemplateInstance)
  1370.     #SET(%LookupControl,%Control)
  1371.   #ENDFOR
  1372.   #FIX(%Control,%ControlToLookup)
  1373.   #IF(%ControlType<>'ENTRY')
  1374.     #ERROR(%Procedure & 'Error: File Lookup needs to refer to Entry Control')
  1375.   #ENDIF
  1376.   #IF(NOT %PreLookupKey AND NOT %PostLookupKey)
  1377.     #ERROR(%Procedure & 'Error: File Lookup needs Entry Control to perform a Pre or Post-Edit lookup')
  1378.   #ENDIF
  1379. #ENDAT
  1380. #AT(%ControlEventHandling,%LookupControl,'Accepted')
  1381.   #FIX(%Control,%ControlToLookup)
  1382.   #IF(NOT %PostLookupKey)
  1383.     #FIND(%Field,%ControlUse)
  1384.     #FOR(%Relation),WHERE(%RelationKey = %PreLookupKey)
  1385.       #IF(%FileRelationType = 'MANY:1')
  1386.         #FOR(%FileKeyField),WHERE(%FileKeyFieldLink)
  1387.           #IF(%FileKeyFieldLink = %PreLookupField)
  1388.             #BREAK
  1389.           #ENDIF
  1390. %FileKeyFieldLink = %FileKeyField
  1391.         #ENDFOR
  1392.       #ENDIF
  1393.     #ENDFOR
  1394. %PreLookupField = %ControlUse
  1395. GlobalRequest = SelectRecord
  1396. %PreLookupProcedure
  1397. LocalResponse = GlobalResponse
  1398. IF LocalResponse = RequestCompleted
  1399.     #FIND(%Field,%ControlUse)
  1400.     #FOR(%Relation),WHERE(%RelationKey = %PreLookupKey)
  1401.       #IF(%FileRelationType = 'MANY:1')
  1402.         #FOR(%FileKeyField),WHERE(%FileKeyFieldLink)
  1403.           #IF(%FileKeyFieldLink = %PreLookupField)
  1404.             #BREAK
  1405.           #ENDIF
  1406.   %FileKeyField = %FileKeyFieldLink
  1407.         #ENDFOR
  1408.       #ENDIF
  1409.     #ENDFOR
  1410.   %ControlUse = %PreLookupField
  1411. END
  1412.   #ELSE
  1413.     #FOR(%Relation),WHERE(%RelationKey = %PostLookupKey)
  1414.       #IF(%FileRelationType = 'MANY:1')
  1415.         #FOR(%FileKeyField),WHERE(%FileKeyFieldLink)
  1416.           #IF(%FileKeyFieldLink = %PostLookupField)
  1417.             #BREAK
  1418.           #ENDIF
  1419. %FileKeyFieldLink = %FileKeyField
  1420.         #ENDFOR
  1421.       #ENDIF
  1422.     #ENDFOR
  1423. %PostLookupField = %ControlUse
  1424. GlobalRequest = SelectRecord
  1425. %PostLookupProcedure
  1426. LocalResponse = GlobalResponse
  1427. IF LocalResponse = RequestCompleted
  1428.     #FOR(%Relation),WHERE(%RelationKey = %PostLookupKey)
  1429.       #IF(%FileRelationType = 'MANY:1')
  1430.         #FOR(%FileKeyField),WHERE(%FileKeyFieldLink)
  1431.           #IF(%FileKeyFieldLink = %PostLookupField)
  1432.             #BREAK
  1433.           #ENDIF
  1434.   %FileKeyField = %FileKeyFieldLink
  1435.         #ENDFOR
  1436.       #ENDIF
  1437.     #ENDFOR
  1438.   %ControlUse = %PostLookupField
  1439. END
  1440.   #ENDIF
  1441. ForceRefresh = True
  1442. LocalRequest = OriginalRequest
  1443. DO RefreshWindow
  1444. #FIX(%Control,%LookupControl)
  1445. #ENDAT